import { EntitySchema } from '@mikro-orm/core';

export class LeUserStatistical {
  id!: string;
  UID!: string;
  buyNumber: number = 0;
  buyAmount!: string;
  lastBuyTime?: string;
  lastVisitTime?: string;
  createdTime!: string;
  updatedTime?: string;
  deletedTime?: string;
  isDeleted: boolean = false;
}

export const LeUserStatisticalSchema = new EntitySchema({
  class: LeUserStatistical,
  properties: {
    id: { primary: true, type: 'string', columnType: 'bigint' },
    UID: { type: 'string', fieldName: 'UID', columnType: 'bigint', index: '用户id' },
    buyNumber: { type: 'number', default: 0 },
    buyAmount: { type: 'string', columnType: 'numeric(10,2)', defaultRaw: `0.00` },
    lastBuyTime: { type: 'string', columnType: 'bigint', nullable: true },
    lastVisitTime: { type: 'string', columnType: 'bigint', nullable: true },
    createdTime: { type: 'string', columnType: 'bigint' },
    updatedTime: { type: 'string', columnType: 'bigint', nullable: true },
    deletedTime: { type: 'string', columnType: 'bigint', nullable: true },
    isDeleted: { type: 'boolean', default: false },
  },
});
